{include file='public:header-css'/}
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        {include file='public:left-menu'/}
        <!--End 左侧导航-->
        <!--头部信息-->
        {include file='public:nav-header' title="交易管理" subTitle="添加编辑某票"/}
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-body">
                                <form method="post" id="submit-form" class="">
                                    <div class="form-group row">
                                        <div class="col-md-6">
                                            <label class="form-title"><em class="require">*</em>手机号码</label>
                                            {if $info}
                                            <input type="text" class="form-control" value="{$info.user.mobile}" disabled/>
                                            {else/}
                                            <input type="text" class="form-control" name="mobile" placeholder="请输入手机号码"/>
                                            {/if}
                                            <small class="help">会员手机号码</small>
                                            <span class="error" id="err_mobile"></span>
                                        </div>
                                        <div class="col-md-6">
                                            <label class="form-title"><em class="require">*</em>选择钱包</label>
                                            {if $info}
                                            <input type="text" class="form-control" value="{$info.qianbao.name}" disabled/>
                                            {else/}
                                            <select class="input-group-select w-100" name="wid">
                                                {volist name="$wallet" id="wallet"}
                                                <option value="{$wallet.id}">{$wallet.name}</option>
                                                {/volist}
                                            </select>
                                            {/if}
                                            <small class="help">选择钱包类型</small>
                                            <span class="error" id="err_wid"></span>
                                        </div>
                                    </div>
                                    {if $info}
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <label class="form-title">可用资金</label>
                                            <div class="form-inline">
                                                <div class="item">
                                                    <span>{$info.qianbao.name}</span>
                                                    <span>{$info.money}</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    {/if}
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <label class="form-title"><em class="require">*</em>变动金额</label>
                                            <input type="text" class="form-control" name="money" placeholder="请输入变动金额"/>
                                            <span class="error" id="err_money"></span>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <label class="form-title">操作备注</label>
                                            <textarea class="form-control" name="desc" rows="3" placeholder="不填写则默认为管理调整"></textarea>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <input type="hidden" name="id" value="{$info.id}">
                                            <button type="button" class="btn-theme submit-btn">确定</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<style>
    .form-inline .item{
        margin-right: 5px;
    }
    .form-inline .item span:last-child{
        color: var(--red);
    }
</style>
<script type="text/javascript">
    $(function () {
        $('.submit-btn').click(function () {
            $('span.error').hide();
            $('.has-error').removeClass('has-error');
            var url = "{:url('Deal/add_user_wallet')}";
            var data = $('#submit-form').serialize();
            public_ajax(url,data,function (data) {
                if (data.code == 1) {
                    showSuccessMsg(data.msg, function () {
                        if (data.data.url) {
                            location.href = data.data.url;
                        }
                    });
                } else if (data.code == 10) {
                    showErrorMsg(data.msg);
                    $.each(data.data.result, function(index, item) {
                        $('#err_' + index).text(item).show();
                        $('#err_' + index).parent().addClass('has-error');
                    });
                } else {
                    showErrorMsg(data.msg);
                }
            });
        });
    });
</script>
</body>
</html>
